package cn.jiyun.ai.impl;

import cn.jiyun.ai.DoctorService;
import cn.jiyun.ai.common.Result;
import cn.jiyun.ai.mapper.DoctorMapper;
import cn.jiyun.ai.pojo.Doctor;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements DoctorService {
    @Autowired
    DoctorMapper doctorMapper;

    @Override
    public Result findDoctorList() {
        QueryWrapper<Doctor> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().orderByDesc(Doctor::getActivityLevel);
        List<Doctor> doctorList=doctorMapper.selectList(queryWrapper);
        return Result.ok(doctorList);
    }

    @Override
    public Result selectDoctorById(Integer id) {
        QueryWrapper<Doctor> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(Doctor::getId,id);
        Doctor doctor = doctorMapper.selectOne(queryWrapper);
        return Result.ok(doctor);
    }
}
